home *** CD-ROM | disk | FTP | other *** search
/ PC World 2008 April / PCWorld_2008-04_cd.bin / komercni software / miton / SystemMechanic7Pro.exe / {app} / smhtml.dll / 1033 / HTML / PROGRESSBAR.JS < prev    next >
Text File  |  2008-01-24  |  6KB  |  190 lines

  1. function ProgressBar()
  2. {
  3.   this.ID = "";
  4.   this.Label = "";
  5.   this.Width = "200";
  6.   this.Height = "20";
  7.   this.GraphLabel = "98% free";
  8.   
  9.   this.Show = __ShowProgressBar;
  10.   this.Hide = __HideProgressBar;
  11.   this.Render = __RenderProgressBar;
  12.   this.IsRendered = __IsRenderedProgressBar;
  13.   this.SetLabel = __SetProgressBarLabel;
  14.   this.SetProgress = __SetProgressBarProgress;
  15.   this.SetProgressGraphLabel = __SetProgressGraphLabel;
  16.   this._ShowProgressOnLeft = __ShowProgressOnLeft;
  17.   this.Progress = 0;
  18.   this._Visible = true;
  19.   this._Progress = 0;
  20.   this.ClientID = __GetProgressBarClientID;
  21. }
  22.  
  23. function __IsRenderedProgressBar()
  24. {
  25.   return  Get( "progress_hidWidth_" + this.ID  ) == null ? false : true;
  26. }
  27.  
  28. function __RenderProgressBar()
  29. {
  30.   if (this._Rendered)   return "";
  31.   var content = "";
  32.   var display = "block";
  33.   var full = "inline";
  34.   var zero = "inline";
  35.   var img = "ITS_progressbar_left.gif";
  36.   var textOnBlue ="none";
  37.   var textOnEmptyBar = "inline";
  38.   
  39.   if ( this.Progress == 0 )
  40.   {
  41.     img = "ITS_progressbar_empty_sidebar.gif";
  42.     zero = "none";
  43.   }
  44.   if ( this.Progress == 100 )
  45.     full = "none";
  46.   
  47.   if(this._ShowProgressOnLeft(this.Progress))
  48.   {
  49.     textOnBlue ="inline";
  50.     textOnEmptyBar = "none";
  51.   }
  52.   if (!this._Visible) display = "none";
  53.  
  54.   content += "<div id=\"progress_" + this.ID + "\" style=\"display:" + display + "\">";
  55.   content += "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"100%\" >";
  56.   content += "<tr>";
  57.   content += "<td  ><div  style=\"padding:0 0 3 0;\" id=\"progress_lbl_" + this.ID + "\">" + this.Label + "</div></td>";
  58.   content += "</tr>";
  59.   content += "<tr>";
  60.   content += "<td >";
  61.   
  62.    content += "<input type=\"hidden\" id=\"progress_hidWidth_" + this.ID + "\" value='" + this.Width + "'></input> ";
  63.    
  64.            // progress bar
  65.           content +=  "<table border=\"0\" width=\"" + this.Width + "\" cellspacing=0 cellpadding=0  background=\"ITS_progressbar_empty.gif\" >";
  66.             content +=  "<tr>";
  67.             content +=  "<td  align=left style=\"width: 1px; \"  >";
  68.               content += "<img align=\"absmiddle\"  id=\"progress_img_left_" + this.ID + "\" src=\""+ img +"\">";
  69.             content += "</td>";
  70.             
  71.               content +=  "<td valign=middle align=\"right\" id=\"progress_td_"+ this.ID +"\" style=\"display:"+ zero +"; \" width=\"" + this.Progress + "%\" background=\"ITS_progressbar.gif\" >";
  72.               content +=  "<span class=\"progress_sp_bar_s\" id=\"progress_sp_text_right_"+ this.ID +"\" style=\"display:" + textOnBlue + ";\">" + this.GraphLabel+ "</span>";
  73.               content +=  "</td>";
  74.               
  75.               content +=  "<td style=\"vertical-align:middle;display:"+ zero +"; \" id=\"progress_td_middle_"+ this.ID +"\" ><img align=\"absmiddle\" src=\"ITS_progressbar_left.gif\" >";
  76.               content += "<span  class=\"progress_sp_emptybar_s\"  id=\"progress_sp_text_left_"+ this.ID +"\"  style=\"display:" + textOnEmptyBar + ";padding:0px 0px 0px 5px;white-space:nowrap;\" >" + this.GraphLabel+ "</span>";
  77.               content +=  "</td>";
  78.               
  79.               content +=  "<td  align=right style=\"display:"+ full +"; \" id=\"progress_td_right_"+ this.ID +"\"   >";
  80.               content +=  "<img  align=\"absmiddle\"  src=\"ITS_progressbar_empty_sidebar.gif\">";
  81.               content +=  "</td>";
  82.             content +=  "</tr>";
  83.           content +=   "</table>";
  84.         
  85.    content += "</td>";
  86.   content += "</tr>";
  87.   content += "</table>";
  88.   content += "</div>";
  89.   return content;
  90. }
  91.  
  92. function __ShowProgressOnLeft(progress)
  93. {
  94.   return (progress >= 20);
  95. }
  96.  
  97.  
  98. function __SetProgressBarLabel(label)
  99. {
  100.   var element = document.getElementById("progress_lbl_" + this.ID);
  101.   element.innerHTML = label;
  102. }
  103.  
  104. function __SetProgressBarProgress(progress)
  105. {
  106.    if(progress>100)
  107.      progress = 100;
  108.   if(progress<0)
  109.      progress = 0;
  110.  
  111.   var element = Get("progress_td_" + this.ID);
  112.   element.style.width = progress + "%";
  113.   
  114.   var hidWidth = Get("progress_hidWidth_" + this.ID);
  115.   var width = hidWidth.value;
  116.   var bln = this._ShowProgressOnLeft(progress);
  117.   
  118.   SetDisplayWidget("progress_sp_text_right_" + this.ID, bln);
  119.   SetDisplayWidget("progress_sp_text_left_" + this.ID, !bln);
  120.   
  121.   
  122.   
  123.   if( progress == 100 )
  124.      Get("progress_td_right_" + this.ID).style.display = "none";
  125.   else
  126.      Get("progress_td_right_" + this.ID).style.display = "inline";
  127.      
  128.   if( progress == 0 )
  129.   {
  130.      Get("progress_img_left_" + this.ID).src = "ITS_progressbar_empty_sidebar.gif";
  131.      Get("progress_td_" + this.ID).style.display = "none";
  132.      Get("progress_td_middle_" + this.ID).style.display = "none";
  133.   }
  134.   else
  135.   {
  136.      Get("progress_img_left_" + this.ID).src = "ITS_progressbar_left.gif";
  137.      Get("progress_td_" + this.ID).style.display = "inline";
  138.      Get("progress_td_middle_" + this.ID).style.display = "inline";
  139.   }
  140. }
  141.  
  142. function __SetProgressGraphLabel(Value)
  143. {
  144.   if(!this.IsRendered()) return;
  145.   Get("progress_sp_text_right_"+ this.ID).innerHTML = Value;
  146.   Get("progress_sp_text_left_"+ this.ID).innerHTML = Value;
  147. }
  148.  
  149. function __HideProgressBar()
  150. {
  151.   var element = document.getElementById("progress_" + this.ID);
  152.   element.style.display = "none";
  153. }
  154.  
  155. function __ShowProgressBar()
  156. {
  157.   var element = document.getElementById("progress_" + this.ID);
  158.   element.style.display = "block";
  159. }
  160.  
  161. function __GetProgressBarClientID()
  162. {
  163.   return "progress_" + this.ID;
  164. }
  165.  
  166.  
  167.  
  168.  
  169. function pro1()
  170. {
  171.   p = new ProgressBar();
  172.   p.ID = "s";
  173.   p.Width = "333";
  174.   p.Progress = 50;
  175.   Get('divHardDriveProgressBar').innerHTML = p.Render();
  176.   
  177.   //alert('s');
  178. }
  179. var x = 0;
  180.  
  181.  
  182. function pro2()
  183. {
  184.   p = new ProgressBar();
  185.   p.ID = "s";
  186.   p.SetProgress(0);
  187.   x += 10;
  188. }
  189.  
  190.